package com.taotao.manage.controller.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.taotao.common.pojo.ItemCatResult;
import com.taotao.manage.service.ItemCatService;

/**
 * 提供数据的api接口
 * @author joedy
 *
 */
@Controller
@RequestMapping("api/item/cat")
public class ApiItemCatController {
	
	@Autowired
	private ItemCatService itemCatService;
	
	@GetMapping
	public ResponseEntity<ItemCatResult> queryItemCatResult() {
		
		try {
			ItemCatResult result = this.itemCatService.queryItemCatResult();
			if(result == null){
				return ResponseEntity.notFound().build();
			}
			return ResponseEntity.ok(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
	}
}
